home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Ant Movie Catalog 3.5.0.2 / amc_install.exe / {app} / Scripts / Allocine (FR).ifs < prev    next >
Text File  |  2005-05-25  |  61KB  |  1,618 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=ScorEpioN
  8. Title=AllocinΘ
  9. Description=DonnΘes allocine.fr, Affiche allocine.fr, amazon.fr ou cinefil.com
  10. Site=http://www.allocine.fr
  11. Language=FR
  12. Version=44 du 25/05/2005
  13. Requires=3.5
  14. Comments=Ce script nΘcessite le fichier ScorEpioNCommonScript.pas|.==.| :   ' ( ( ( ( /\ |  "==()))))):     ⌐ ScorEpioN ⌐|       ( ( ( ( \_/
  15. License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
  16. GetInfo=1
  17.  
  18. [Options]
  19. Mise α jour=1|1|0=Oui|1=Non
  20. Mode Films ou SΘries=0|0|0=Films|1=SΘries
  21. Type de Lancement=1|1|0=Cherche le meilleur rΘsultat sans confirmation|1=Demande le titre avant de lancer le script|2=Ne demande pas le titre avant de lancer le script|3=Lancement automatique sur l'adresse web
  22. Format du Titre=3|3|0=Titre en minuscule|1=Titre en majuscule|2=PremiΦre lettre du titre en majuscule|3=PremiΦre lettre de chaque mot du titre en majuscule|4=Formatage identique au site d'origine
  23. Recherche sur le titre=0|0|0=Traduit|1=Original
  24. Titre en double=0|0|0=Garde les titres originaux et traduits mΩme identiques|1=Garde les titres originaux si identiques|2=Garde les titres traduits si identiques
  25. Choix Image=1|1|0=Pas d'affiche|1=Petite affiche allocinΘ|2=Grande affiche allocinΘ|3=Grande affiche amazon.fr|4=Grande affiche Cinefil.com
  26. Acteurs=2|2|0=Ne prend pas la liste des acteurs|1=Prend les noms des acteurs de la page principale|2=Prend la liste complΦte des acteurs ainsi que leur r⌠le et le nom du producteur
  27. Secrets de tournage=2|2|0=Ne prend pas les secrets de tournage|1=Prend les secrets de tournage de la page principale|2=Prend la liste complΦte des secrets de tournage
  28. Note=0|0|0=Moyenne note des spectateurs & des critiques|1=Note des spectateurs (de prΘfΘrence)|2=Notes des critiques (de prΘfΘrence)
  29. Detail Note=1|1|0=Ne met pas le dΘtail des notes dans le champs commentaire|1=DΘtail des notes dans le champs commentaire
  30. Critiques Presse=1|0|0=Aucune critique|1=Critiques presse de la page principale|2=Critiques presse complΦtes
  31. Critiques Spectateurs=0|0|0=Aucune critique|1=Panel de critique|2=Critiques spectateurs de la page principale
  32. Bande-Annonce=0|0|0=Pas de lien vers la B.A.|1=Lien vers la B.A. dans l'url|2=Lien vers la B.A. dans les commentaires
  33. Fiche technique=0|0|0=Oui|1=Non
  34. Disposition=1|1|0=Synopsis et Secrets de tournage dans le champs description|1=Les informations sont dispatchΘes
  35. Fichier de log=1|1|0=Oui|1=Non
  36.  
  37. ***************************************************)
  38.  
  39. program Allocine_FR;
  40. uses
  41.   ScorEpioNCommonScript;
  42.  
  43. const
  44.   VersionScript = '44 du 25/05/2005';
  45.   NomScript = 'ALLOCINE';
  46.   urlDomain = 'allocine.fr';
  47.   urlAllocine = 'http://www.allocine.fr';
  48.   urlAllocineSearch = urlAllocine+'/recherche/?motcle=';
  49.   urlAllocineSearchEndFilm = '&rub=1';
  50.   urlAllocineSearchEndSeries = '&rub=6';
  51.   urlAllocineCriSpec = '/film/critiquepublic_gen_cfilm=';
  52.   urlAllocineCriSpecS ='/series/critiquePublic_gen_cserie=';
  53.   urlAmazonImage = 'http://images-eu.amazon.com/images/P/';
  54.   timetosleep = 500;
  55.  
  56. var
  57.   MovieName, ID, AdressePlus, La_liste, LaGrandeImage, LaPremiereGrandeImage, Reponse, AdresseSuivant, AdressePrecedent, LePremierFilmAdresse, strTemp, aucunAmazon, lannee, lanneeCinefil : string;
  58.   numPage, numPageG, numPageR, grandeTaille, premiereTaille, compteur, premiereExecution, numTemp, i : Integer;
  59.   listeResultat : TStringList;
  60.   listeMessagesF, listeMessagesS : array of string;
  61.  
  62. //------------------------------------------------------------------------------
  63. // CONVERSION DE L'URL
  64. //------------------------------------------------------------------------------
  65.  
  66. function convertURL(url : String) : string;
  67. begin
  68.   
  69.   SetArrayLength(listeMessagesF,5);
  70.   SetArrayLength(listeMessagesS,5);
  71.   listeMessagesF[0] := 'fichefilm_gen_cfilm';
  72.   listeMessagesS[0] := 'ficheserie_gen_cserie';
  73.   listeMessagesF[1] := 'fichefilm.html';
  74.   listeMessagesS[1] := 'ficheserie.html';
  75.   listeMessagesF[2] := '/film/fichefilm_gen_cfilm=';
  76.   listeMessagesS[2] := '/series/ficheserie_gen_cserie=';
  77.   listeMessagesF[3] := 'cfilm=';
  78.   listeMessagesS[3] := 'cserie=';
  79. // Converti les url http://www.allocine.fr/film/fichefilm.html?cfilm=3746 en http://www.allocine.fr/film/fichefilm_gen_cfilm=3746.html
  80.   if pos(listeMessagesF[0],url) <> 0 then
  81.      result := url
  82.   else if pos(listeMessagesF[1],url) <> 0 then
  83.      result := urlAllocine+listeMessagesF[2]+copy(url,pos(listeMessagesF[3],url)+length(listeMessagesF[3]),length(url)-1)+'.html'
  84.   else if pos(listeMessagesS[0],url) <> 0 then
  85.      result := url
  86.   else if pos(listeMessagesS[1],url) <> 0 then
  87.      result := urlAllocine+listeMessagesS[2]+copy(url,pos(listeMessagesS[3],url)+length(listeMessagesS[3]),length(url)-1)+'.html';
  88. end;
  89.  
  90. //------------------------------------------------------------------------------
  91. // RETOURNE ELEMENT FILMS OU SERIES
  92. //------------------------------------------------------------------------------
  93.  
  94. function retourneElement(j : Integer) : string;
  95. begin
  96.   if (GetOption('Mode Films ou SΘries') = 0) then
  97.     result := listeMessagesF[j]
  98.   else if (GetOption('Mode Films ou SΘries') = 1) then
  99.     result := listeMessagesS[j];
  100. end;
  101.  
  102. //------------------------------------------------------------------------------
  103. // CALCUL DE LA NOTE
  104. //------------------------------------------------------------------------------
  105.  
  106. function calculMoyenne(Value : String; Echelle : Integer) : string;
  107. begin
  108.     result := FloatToStr(((StrToInt(Value,3)*10) / Echelle));
  109. end;
  110.  
  111. //------------------------------------------------------------------------------
  112. // ANALYSE DE LA PAGE DE RECHERCHES
  113. //------------------------------------------------------------------------------
  114.  
  115. procedure AnalyzePage(Address: string);
  116. var
  117.   Line: string;
  118.   BeginPos, EndPos : Integer;
  119. begin
  120.   Line := GetPage(Address);
  121.  
  122.   SetArrayLength(listeMessagesF,2);
  123.   SetArrayLength(listeMessagesS,2);
  124.   listeMessagesF[0] := 'Aucun film trouvΘ';
  125.   listeMessagesS[0] := 'Aucune sΘrie trouvΘe';
  126.   listeMessagesF[1] := '<b>Films <h4>';
  127.   listeMessagesS[1] := '<b>SΘries TV <h4>';
  128.  
  129.   if pos('Recherche : <b>""</b>', Line) <> 0 then
  130.      exit;
  131.  
  132.   if pos('Pas de rΘsultats',Line) <> 0 then
  133.   begin
  134.     if (GetOption('Type de Lancement') = 1) or (GetOption('Type de Lancement') = 2) then
  135.     begin
  136.       showmessage(retourneElement(0)+' pour : '+MovieName);
  137.       exit;
  138.     end else
  139.     begin
  140.       SetField(fieldChecked, '');
  141.       exit;
  142.     end;
  143.   end;
  144.  
  145.   if pos('Recherche :', Line) = 0 then
  146.   begin
  147.     AnalyzeMoviePage(Address);
  148.   end else
  149.   begin
  150.     PickTreeClear;
  151.     if pos(retourneElement(1), Line) > 0 then
  152.       AddMoviesTitles(findInfo('<td colspan="2" valign="top">', '</table>', Line,'1'));
  153.     //menuScorEpioN();
  154.     if compteur = 1 then
  155.     begin
  156.       compteur := 0;
  157.       AnalyzeMoviePage(copy(listeResultat.GetString(0),pos('|',listeResultat.GetString(0))+1,pos('[',listeResultat.GetString(0))-pos('|',listeResultat.GetString(0))-1));
  158.       exit;
  159.     end else if (GetOption('Type de Lancement') = 1) or (GetOption('Type de Lancement') = 2) then
  160.     begin
  161.       begin
  162.         if PickTreeExec(Address) then
  163.         begin
  164.           //if execMenuScorEpioN(urlDomain, Address) = False then
  165.           //begin
  166.             if (Address = AdressePlus) then
  167.             begin
  168.               numPageR := numPageR+1;
  169.                 AnalyzePage(AdressePlus);
  170.             end else
  171.             if (Address = AdressePrecedent) then
  172.             begin
  173.               numPageR := numPageR-1;
  174.                 AnalyzePage(AdressePrecedent);
  175.             end else
  176.             if (Address = AdresseSuivant) then
  177.             begin
  178.               numPageR := numPageR+1;
  179.                 AnalyzePage(AdresseSuivant);
  180.             end else
  181.             begin
  182.               AnalyzeMoviePage(Address);
  183.             end;
  184.           //end;
  185.         end;
  186.       end;
  187.     end else
  188.     begin
  189.       if (GetOption('Type de Lancement') = 0) then
  190.       begin
  191.         sleep(timetosleep);
  192.         if trouveResultat(MovieName) <> '' then
  193.           AnalyzeMoviePage(trouveResultat(MovieName));
  194.       end ;
  195.     end;
  196.   end;
  197. end;
  198.  
  199. //------------------------------------------------------------------------------
  200. // TROUVE LE BON RESULTAT
  201. //------------------------------------------------------------------------------
  202.  
  203. function trouveResultat(title : String) : String;
  204. var
  205.    oK, couple, titre, adresse : String;
  206. begin
  207.    for i:=0 to listeResultat.Count-1 do
  208.    begin
  209.      couple := listeResultat.GetString(i);
  210.      titre := copy(couple,0,pos('|',couple)-1);
  211.      adresse := copy(couple,pos('|',couple)+1,pos('[',couple)-pos('|',couple)-1);
  212.      oK := compareTitle(title,titre);
  213.      if oK = 'OK' then
  214.      begin
  215.        lannee := copy(couple,pos('[',couple),length(couple));
  216.        result := adresse;
  217.        exit;
  218.      end;
  219.    end;
  220.    if oK = 'KO' then
  221.      result := '';
  222.    listeResultat.Free;
  223.  
  224. end;
  225.  
  226. //------------------------------------------------------------------------------
  227. // ANALYSE DE LA PAGE DU FILM
  228. //------------------------------------------------------------------------------
  229.  
  230. procedure AnalyzeMoviePage(Adresse : String);
  231. var
  232.   Line, Value, aucun, Avertissement, Note1, Note2 : string;
  233.   AdresseCasting, AdresseBA, AdresseSecret, AdressePresse, AdresseGalerie : String;
  234.   IntValue, BeginPos, EndPos, FinPos: Integer;
  235. begin
  236. // Pour le mode Batch
  237.   if (GetOption('Fichier de log') = 0) then
  238.     beforeUpdate();
  239.   
  240.   SetArrayLength(listeMessagesF,1);
  241.   SetArrayLength(listeMessagesS,1);
  242.   listeMessagesF[0] := '/film/fichefilm_gen_cfilm=';
  243.   listeMessagesS[0] := '/series/ficheserie_gen_cserie=';
  244.  
  245. // Charge la page
  246.   Line := GetPage(Adresse);
  247.   Avertissement := '';
  248.   if pos(listeMessagesF[0],Adresse) <> 0 then
  249.      ID := findInfo(listeMessagesF[0], '.html', Adresse,'0')
  250.   else if pos(listeMessagesS[0],Adresse) <> 0 then
  251.      ID := findInfo(listeMessagesS[0], '.html', Adresse,'0');
  252.  
  253.   if (pos('ficheserie',Adresse) <> 0) then
  254.   begin
  255.        AnalyzeSeriePage(Adresse,Line);
  256.        exit;
  257.   end;
  258.  
  259. // RΘcupΘration des urls optionnelles
  260.   if (GetOption('Bande-Annonce') <> 0) then
  261.       AdresseBA := ladressedelaBA(Line);
  262.   if (GetOption('Acteurs') =2) then
  263.       AdresseCasting := ladresseduCasting(Line);
  264.   if (GetOption('Secrets de tournage') = 2) then
  265.       AdresseSecret := ladressedesSecrets(Line);
  266.   if (GetOption('Critiques Presse') = 2) then
  267.       AdressePresse := ladressedesCritiques(Line);
  268.  
  269. // URL
  270.   if CanSetField(fieldURL) then
  271.     SetField(fieldURL, URLEncode(Adresse));
  272.  
  273. // Bande-Annonce (option 1)
  274.   if (GetOption('Bande-Annonce') = 1) and CanSetField(fieldURL) and (AdresseBA <> '') then
  275.     SetField(fieldURL, URLEncode(AdresseBA));
  276.  
  277. //translated title
  278.   if CanSetField(fieldTranslatedTitle) then
  279.     MonSetField(fieldTranslatedTitle, formatTitre(findInfo('<title>', '</title>', Line,'0'),GetOption('Format du Titre')));
  280.     
  281. // Original Title
  282.   if CanSetField(fieldOriginalTitle) then
  283.   begin
  284.     Value := findInfo('<h4>Titre original : ', '</h4>', Line,'0');
  285.     if (Value <> '') then
  286.       MonSetField(fieldOriginalTitle, formatTitre(Value,GetOption('Format du Titre')))
  287.     else
  288.       SetField(fieldOriginalTitle, GetField(fieldTranslatedTitle));
  289.   end;
  290.  
  291. // Picture
  292.   aucunAmazon := 'aucune image';
  293.   if CanSetPicture then
  294.   begin
  295.     if GetOption('Recherche sur le titre') = 0 then
  296.        Value := GetField(fieldTranslatedTitle)
  297.     else
  298.        Value := GetField(fieldOriginalTitle);
  299.     if (GetOption('Choix Image') = 3) then
  300.     begin
  301.       imageAmazon(Value);
  302.       returnGrandeImage(Line);
  303.       returnPetiteImage(Line);
  304.     end else if (GetOption('Choix Image') = 4) then
  305.     begin
  306.       anneeFilmCourant(Line);
  307.       imageCinefil(Value);
  308.       returnGrandeImage(Line);
  309.       returnPetiteImage(Line);
  310.     end else if (GetOption('Choix Image') = 1) then
  311.     begin
  312.       returnPetiteImage(Line);
  313.     end else if (GetOption('Choix Image') = 2) then
  314.     begin
  315.         returnGrandeImage(Line);
  316.         returnPetiteImage(Line);
  317.     end;
  318.   end; // CanSetPicture
  319.  
  320. // Director
  321.     if CanSetField(fieldDirector) then
  322.       MonSetField(fieldDirector, formatTitre(findInfo('<h4>RΘalisΘ par ', '</h4>', Line,'0'),GetOption('Format du Titre')));
  323.  
  324. // Actors
  325.   if CanSetField(fieldActors) and (GetOption('Acteurs') = 1) then
  326.     MonSetField(fieldActors, formatTitre(findInfo('<h4>Avec ', '</h4>', Line,'0'),GetOption('Format du Titre')));
  327.  
  328. //Country
  329.     if CanSetField(fieldCountry) then
  330.       MonSetField(fieldCountry, formatTitre(transformCountry(deleteEnd(findInfo('<h4>Film ', '</h4>', Line,'0'),'.')),GetOption('Format du Titre')));
  331.  
  332. // Category
  333.     if CanSetField(fieldCategory) then
  334.       MonSetField(fieldCategory, formatTitre(findInfo('<h4>Genre : ', '</h4>', Line,'0'),GetOption('Format du Titre')));
  335.  
  336. // Length
  337.     if CanSetField(fieldLength) then
  338.     begin
  339.       if pos('DurΘe : ', Line) > 0 then
  340.       begin
  341.         Delete(Line, 1, pos('DurΘe : ', Line) + 7);
  342.         IntValue := StrToInt(copy(Line, 1, 1), 0) * 60;
  343.         if pos('min.', Line) > 0 then
  344.         begin
  345.           delete(Line,1,pos('h', Line) + 1);
  346.           Value := copy(Line, 1, pos('min.',Line)-1);
  347.           Value := StringReplace(Value, ' ', '');
  348.           IntValue := IntValue + StrToInt(Value, 0);
  349.         end;
  350.         SetField(fieldLength, IntToStr(IntValue));
  351.       end;
  352.     end;
  353.  
  354. // Year
  355.     if CanSetField(fieldYear) then
  356.       MonSetField(fieldYear, findInfo('<h4>AnnΘe de production : ', '</h4>', Line,'0'));
  357.  
  358. // Avertissement
  359.    BeginPos := pos('Interdit', Line);
  360.    if (BeginPos > 0) then
  361.    begin
  362.        Delete(Line, 1, BeginPos-1);
  363.      EndPos := pos('</h4>', Line);
  364.      Avertissement := copy(Line, 1, EndPos - 1)+#13#10#13#10;
  365.      if CanSetField(fieldComments) then
  366.        SetField(fieldComments, Trim(Avertissement));
  367.    end;
  368.  
  369. // Productor + More actors
  370.   if (GetOption('Acteurs') = 2) AND (AdresseCasting <> '') then
  371.     castingComplet(AdresseCasting);
  372.  
  373.  
  374. // Rating
  375.     if (pos('<h4>Critiques :', Line) > 0) then
  376.     begin
  377.       Note1 := '';
  378.       Note2 := '';
  379.       Delete(Line, 1, pos('<h4>Critiques :', Line) + 14);
  380.       Value := copy(Line,1,pos('Ecrivez votre critique',Line));
  381.       if pos('Presse', Value) > 0 then
  382.       begin
  383.         Note1 := findInfo('etoile_', '.gif', Value,'0');
  384.         Delete(Line, 1, pos('.gif', Value)+3);
  385.         if GetOption('Detail Note') = 1 then
  386.           Avertissement := Avertissement + 'Note de la presse : ' + Note1 + '/4 ';
  387.       end;
  388.       if pos('Spectateurs', Value) > 0 then
  389.         begin
  390.         Note2 := findInfo('etoile_', '.gif', Value,'0');
  391.         Delete(Line, 1, pos('.gif', Value)+3);
  392.         if GetOption('Detail Note') = 1  then
  393.           Avertissement := Avertissement + 'Note des spectateurs : ' + Note2 + '/4';
  394.       end;
  395.       if CanSetField(fieldComments) and (GetOption('Detail Note') = 1)  then // DΘtail des notes dans les commentaires
  396.       begin
  397.         Avertissement := Avertissement + #13#10#13#10;
  398.         SetField(fieldComments, Avertissement);
  399.       end;
  400.       if CanSetField(fieldRating) then // Notes dans le champs note
  401.       begin
  402.         if GetOption('Note') = 1 then
  403.         begin
  404.           if Note2 <> '' then
  405.             SetField(fieldRating,calculMoyenne(Note2,4))
  406.           else
  407.             SetField(fieldRating,calculMoyenne(Note1,4));
  408.         end else
  409.         if GetOption('Note') = 2 then
  410.         begin
  411.           if Note1 <> '' then
  412.             SetField(fieldRating,calculMoyenne(Note1,4))
  413.           else
  414.             SetField(fieldRating,calculMoyenne(Note2,4));
  415.         end else
  416.         if GetOption('Note') = 0 then
  417.         begin
  418.           if (Note1 <> '') and (Note2 <> '') then
  419.             Note1 := IntToStr(StrToInt(Note1,1)+StrToInt(Note2,1))
  420.           else
  421.           if (Note1 <> '') then
  422.             Note1 := IntToStr(StrToInt(Note1,1)+StrToInt(Note1,1))
  423.           else
  424.           if (Note2 <> '') then
  425.             Note1 := IntToStr(StrToInt(Note2,1)+StrToInt(Note2,1));
  426.           SetField(fieldRating,calculMoyenne(Note1,8));
  427.         end;
  428.       end;
  429.     end;
  430.     
  431. // Bande-Annonce (option 2)
  432.   if CanSetField(fieldComments) and(GetOption('Bande-Annonce') = 2) and (AdresseBA <> '') then
  433.   begin
  434.     Avertissement := Avertissement+'Bande Annonce : '+AdresseBA+#13#10#13#10;
  435.     SetField(fieldComments, Avertissement);
  436.   end;
  437.  
  438. // Fiche technique
  439.   if CanSetField(fieldComments) and (GetOption('Fiche technique') = 0) then
  440.   begin
  441.     if Pos('<b>Fiche Technique</b>', Line) > 0 then
  442.     begin
  443.       Value := Line;
  444.       delete(Value, 1 ,pos('<b>Fiche Technique</b></h3>', Value));
  445.       Value := findInfo('<h4><b>', '</td></tr>', Value,'-1');
  446.       Avertissement := Avertissement+'Fiche technique :'+#13#10#13#10+Value+#13#10;
  447.       MonSetField(fieldComments, Avertissement);
  448.     end;
  449.   end;
  450.  
  451. // Description
  452.   if CanSetField(fieldDescription) then
  453.   begin
  454.     if pos('<b>Synopsis', Line) > 0 then
  455.     begin
  456.      Delete(Line, 1, pos('<b>Synopsis', Line));
  457.      MonSetField(fieldDescription, findInfo('<h4>', '</h4>', Line,'-1'));
  458.     end;
  459.   end;
  460.  
  461. // Commments
  462.   if CanSetField(fieldComments) then
  463.   begin
  464.     if (pos('<b>Secrets de tournage', Line) > 0) and (GetOption('Secrets de tournage') = 1) then
  465.     begin
  466.      Delete(Line, 1, pos('<b>Secrets de tournage', Line));
  467.      Delete(Line, 1, pos('</table>', Line)+7);
  468.      Value := Avertissement+'Secrets de tournage :'+#13#10#13#10;
  469.      BeginPos := pos('<td colspan="3" valign="top" style="padding:">', Line);
  470.      repeat
  471.        BeginPos := pos('<td colspan="3" valign="top" style="padding:">', Line);
  472.        delete(Line, 1, BeginPos-1);
  473.        // titre
  474.        aucun := findInfo('<td colspan="3" valign="top" style="padding:">', '</b></h4></td>', Line,'0');
  475.        Value := Value+formatTitre(aucun,GetOption('Casse Choisie'))+#13#10;
  476.        // secret
  477.        aucun := findInfo('justify"><h4>', '</h4></div></td>', Line,'0');
  478.        Value := Value+aucun+#13#10#13#10;
  479.        delete(Line, 1, length('<td colspan="3" valign="top" style="padding:">'));
  480.        BeginPos := pos('<td colspan="3" valign="top" style="padding:">', Line);
  481.      until (BeginPos = 0);
  482.      SetField(fieldComments, Trim(Value));
  483.     end else
  484.     if (AdresseSecret <> '') and (GetOption('Secrets de tournage') = 2) then
  485.     begin
  486.      La_liste := Avertissement+'Secrets de tournage :'+#13#10#13#10;
  487.      numPage := 1;
  488.      secretComplet(AdresseSecret);
  489.     end;
  490.   end;
  491.  
  492. // Critiques presse
  493.   if CanSetField(fieldComments) then
  494.   begin
  495.     if ((GetOption('Critiques Presse') <> 0) and (pos('<b>Critiques Presse</b></h3>', Line) > 0)) then
  496.     begin
  497.       Value := GetField(fieldComments)+'Critiques Presse :'+#13#10#13#10;
  498.       delete(Line,1, pos('<b>Critiques Presse</b></h3>', Line)+length('<b>Critiques Presse</b></h3>')+1);
  499.       if (GetOption('Critiques Presse') =1) then
  500.       begin
  501.         repeat
  502.           // DΘbut boucle
  503.           BeginPos := pos('<td valign="top"><h4><b>', Line);
  504.           delete(Line, 1, BeginPos-1);
  505.           // Journal et nom du critique
  506.           aucun := findInfo('<h4><b>', '</h4><img', Line,'0');
  507.           Value := Value+formatTitre(aucun,GetOption('Casse Choisie'));
  508.           // Note
  509.           aucun := findInfo('etoile_', '.gif', Line,'0');
  510.           Value := Value+' - Note : '+aucun+ '/4 '+#13#10;
  511.           // la critique
  512.           aucun := findInfo('<div align="justify"><h4>', '</h4></div>', Line,'0');
  513.           aucun := StringReplace(aucun, '    ', '');
  514.           Value := Value+aucun+#13#10#13#10;
  515.           // Fin Boucle
  516.           delete(Line, 1, length('<td valign="top"><h4><b>'));
  517.           BeginPos := pos('<td valign="top"><h4><b>', Line);
  518.         until (BeginPos = 0);
  519.         SetField(fieldComments, Trim(Value));
  520.       end else if (GetOption('Critiques Presse') = 2) and (adressePresse <> '') then
  521.       begin
  522.         La_liste := Value;
  523.         numPage := 1;
  524.         critiquesPresseComplet(adressePresse);
  525.       end;
  526.     end;
  527.   end;
  528.  
  529. // Critiques Spectateurs
  530.   if CanSetField(fieldComments) then
  531.   begin
  532.     if ((GetOption('Critiques Spectateurs') <> 0) and (pos('<b>Critiques Spectateurs</b></h3>', Line) > 0)) then
  533.     begin
  534.       Value := GetField(fieldComments)+'Critiques Spectateurs :'+#13#10#13#10;
  535.       delete(Line,1, pos('<b>Critiques Spectateurs</b></h3>', Line)+length('<b>Critiques Spectateurs</b></h3>')+1);
  536.       if (GetOption('Critiques Spectateurs') =2) then
  537.       begin
  538.         repeat
  539.           // DΘbut boucle
  540.           BeginPos := pos('valign="top"><h4><b>', Line);
  541.           delete(Line, 1, BeginPos-1);
  542.           // nom du spectateur et date
  543.           aucun := findInfo('<h4><b>', '</h4><img', Line,'0');
  544.           Value := Value+formatTitre(aucun,GetOption('Casse Choisie'));
  545.           // Note
  546.           aucun := findInfo('etoile_', '.gif', Line,'0');
  547.           Value := Value+' - Note : '+aucun+ '/4 '+#13#10;
  548.           // la critique
  549.           aucun := findInfo('<div align="justify"><h4>', '</h4></div>', Line,'0');
  550.           aucun := StringReplace(aucun, '    ', '');
  551.           aucun := StringReplace(aucun, 'Lire la suite...', '');
  552.           Value := Value+aucun+#13#10#13#10;
  553.           // Fin Boucle
  554.           delete(Line, 1, length('valign="top"><h4><b>'));
  555.           BeginPos := pos('valign="top"><h4><b>', Line);
  556.         until (BeginPos = 0);
  557.         SetField(fieldComments, Trim(Value));
  558.       end else if (GetOption('Critiques Spectateurs') = 1) then
  559.       begin
  560.         panelCritiquesSpectateurs(Line);
  561.       end;
  562.     end;
  563.   end;
  564.  
  565. // Pour avoir le synopsis et les secrets de tournage dans le champs descriptions
  566.   if (GetOption('Disposition') = 0) then
  567.     moveComments();
  568.  
  569. // Pour le mode Batch
  570.   if (GetOption('Fichier de log') = 0) then
  571.   begin
  572.     AddToLog('Nouvelle Image : '+aucunAmazon);
  573.     afterUpdate();
  574.   end;
  575.  
  576. // Affichage des titres si original et traduit identique
  577.   titreDouble(GetOption('Titre en double'));
  578.  
  579. end;
  580.  
  581. //------------------------------------------------------------------------------
  582. // ANALYSE DE LA PAGE DE LA SERIE
  583. //------------------------------------------------------------------------------
  584.  
  585. procedure AnalyzeSeriePage(Adresse, Line : String);
  586. var
  587.   Value, Value2, Ligne : string;
  588.   BeginPos : Integer;
  589.   listeInfos : TStringList;
  590. begin
  591.  
  592. // URL
  593.   if CanSetField(fieldURL) then
  594.     SetField(fieldURL, URLEncode(Adresse));
  595.  
  596. //translated title
  597.   if CanSetField(fieldTranslatedTitle) then
  598.     MonSetField(fieldTranslatedTitle, nettoieTitre(formatTitre(findInfo('<title>', '</title>', Line,'0'),GetOption('Format du Titre'))));
  599. // Original Title
  600.   if CanSetField(fieldOriginalTitle) then
  601.   begin
  602.     Value := findInfo('<h4><b>Titre original : </b></h4>', '</h4>', Line,'0');
  603.     if (Value <> '') then
  604.       MonSetField(fieldOriginalTitle, nettoieTitre(formatTitre(Value,GetOption('Format du Titre'))))
  605.     else
  606.       SetField(fieldOriginalTitle, GetField(fieldTranslatedTitle));
  607.   end;
  608. // Year
  609.     if CanSetField(fieldYear) then
  610.     begin
  611.       Value := findInfo('<h4>SΘrie crΘΘe', '</h4>', Line,'0');
  612.       Delete(Value,1,pos(' en ',Value)+length(' en ')-1);
  613.       MonSetField(fieldYear, Value);
  614.     end;
  615. // Length
  616.     if CanSetField(fieldLength) then
  617.         SetField(fieldLength, findInfo('Format : ', 'mn.', Line,'0'));
  618. // Description
  619.   if CanSetField(fieldDescription) then
  620.   begin
  621.     if pos('<b>Synopsis</b></h3>', Line) > 0 then
  622.     begin
  623.      Value := Line;
  624.      Delete(Value, 1, pos('<b>Synopsis</b></h3>', Value));
  625.      MonSetField(fieldDescription, findInfo('<h4>', '</h4>', Value,'-1'));
  626.     end;
  627.   end;
  628. // Category
  629.     if CanSetField(fieldCategory) then
  630.       MonSetField(fieldCategory, formatTitre(findInfo('Genre : ', ' - ', Line,'0'),GetOption('Format du Titre')));
  631. // Actors
  632.   if CanSetField(fieldActors) then
  633.   begin
  634.     if (GetOption('Acteurs') = 1) then
  635.     begin
  636.       MonSetField(fieldActors, formatTitre(findInfo('Avec : ', '<img', Line,'0'),GetOption('Format du Titre')));
  637.     end else if (GetOption('Acteurs') = 2) then
  638.     begin
  639.          Value := ladresseduCasting(Line);
  640.          castingComplet(Value);
  641.     end;
  642.   end;
  643. // Picture
  644.   aucunAmazon := 'aucune image';
  645.   if CanSetPicture then
  646.   begin
  647.     if (GetOption('Choix Image') = 3) then
  648.     begin
  649.       imageAmazon(GetField(fieldTranslatedTitle));
  650.       returnSerieImage(Line);
  651.     end else if (GetOption('Choix Image') = 4) then
  652.     begin
  653.       imageAmazon(GetField(fieldTranslatedTitle));
  654.       returnSerieImage(Line);
  655.     end else if (GetOption('Choix Image') = 1) then
  656.     begin
  657.       returnSerieImage(Line);
  658.     end else if (GetOption('Choix Image') = 2) then
  659.     begin
  660.       returnSerieImage(Line);
  661.     end;
  662.   end;
  663.  
  664. // Initialisation de la liste des infos supplΘmentaires
  665.   listeInfos := TStringList.Create;
  666.  
  667. // Note
  668.   Value := findInfo('Note moyenne : ', 'critiques', Line,'1');
  669.   if (GetOption('Detail Note') = 1) and (findInfo('etoile_', '.gif', Value,'0') <> '') then
  670.     listeInfos.Add('Note moyenne des tΘlΘspectateurs : '+findInfo('etoile_', '.gif', Value,'0')+'/4 '+findInfo('Note moyenne : ', 'critiques', Line,'0')+' critiques.'+#13#10);
  671.   if CanSetField(fieldRating)  and (findInfo('etoile_', '.gif', Value,'0') <> '') then
  672.     SetField(fieldRating,calculMoyenne(findInfo('etoile_', '.gif', Value,'0'),4));
  673.  
  674.   if listeInfos.Count <> 0 then
  675.     listeInfos.Add(#13#10);
  676.  
  677. // Status, Episodes, Saisons
  678.   if findInfo('Saisons : ', ' -', Line,'0') <> '' then
  679.     listeInfos.Add('Saisons : '+findInfo('Saisons : ', ' -', Line,'0')+#13#10);
  680.   if findInfo('Episodes : ', ' -', Line,'0') <> '' then
  681.     listeInfos.Add('Episodes : '+findInfo('Episodes : ', ' -', Line,'0')+#13#10);
  682.   if findInfo('Statut : ', ' -', Line,'0') <> '' then
  683.     listeInfos.Add('Statut : '+findInfo('Statut : ', '</b>', Line,'0')+#13#10#13#10);
  684.  
  685. // 1ere diffusion
  686.   if findInfo('1Φre diffusion : ', ' -', Line,'0') <> '' then
  687.     listeInfos.Add('1Φre diffusion : '+findInfo('1Φre diffusion : ', ' sur', Line,'0')+#13#10);
  688.   if findInfo('1Φre diffusion France : ', ' -', Line,'0') <> '' then
  689.     listeInfos.Add('1Φre diffusion France : '+findInfo('1Φre diffusion France : ', ' sur', Line,'0')+#13#10);
  690.  
  691.   if CanSetField(fieldComments) then
  692.   begin
  693.     Value := '';
  694.     for i:=0 to listeInfos.Count-1 do
  695.     begin
  696.       Value := Value+listeInfos.GetString(i);
  697.     end;
  698.     SetField(fieldComments,Value);
  699.   end;
  700.  
  701.   listeInfos.Free;
  702.  
  703. // Saisons et Θpisodes
  704.   if pos('/series/episodes_gen_cserie='+ID+'.html', Line) <> 0 then
  705.      saisonsETepisodes(urlAllocine+'/series/episodes_gen_cserie='+ID+'.html');
  706.  
  707. // Critiques Spectateurs
  708.   if ((GetOption('Critiques Spectateurs') = 2) and (pos('<b>Critiques Spectateurs</b></h3>', Line) > 0)) then
  709.   begin
  710.     Value := 'Critiques Spectateurs :'+#13#10#13#10;
  711.     Ligne := Line;
  712.     delete(Ligne,1, pos('<b>Critiques Spectateurs</b></h3>', Ligne)+length('<b>Critiques Spectateurs</b></h3>')+1);
  713.     repeat
  714.         // DΘbut boucle
  715.         BeginPos := pos('valign="top"><h4><b>', Ligne);
  716.         delete(Ligne, 1, BeginPos-1);
  717.         // nom du spectateur et date
  718.         Value := Value+formatTitre(findInfo('<h4><b>', '</h4><img', Ligne,'0'),GetOption('Casse Choisie'));
  719.         // Note
  720.         Value := Value+' - Note : '+findInfo('etoile_', '.gif', Ligne,'0')+ '/4 '+#13#10;
  721.         // la critique
  722.         Value2 := findInfo('<div align="justify"><h4>', '</h4></div>', Ligne,'0');
  723.         Value2 := StringReplace(Value2, '    ', '');
  724.         Value2 := StringReplace(Value2, 'Lire la suite...', '');
  725.         Value := Value+Value2+#13#10#13#10;
  726.         // Fin Boucle
  727.         delete(Ligne, 1, length('valign="top"><h4><b>'));
  728.         BeginPos := pos('valign="top"><h4><b>', Ligne);
  729.     until (BeginPos = 0);
  730.     SetField(fieldComments, GetField(fieldComments)+#13#10#13#10+Value);
  731.   end else if (GetOption('Critiques Spectateurs') = 1) then
  732.   begin
  733.      panelCritiquesSpectateurs(Line);
  734.   end;
  735.  
  736. // Pour le mode Batch
  737.   if (GetOption('Fichier de log') = 0) then
  738.   begin
  739.     AddToLog('Nouvelle Image : '+aucunAmazon);
  740.     afterUpdate();
  741.   end;
  742.  
  743. // Affichage des titres si original et traduit identique
  744.   titreDouble(GetOption('Titre en double'));
  745.  
  746. end;
  747.  
  748. //------------------------------------------------------------------------------
  749. // NETTOIE TITRE
  750. //------------------------------------------------------------------------------
  751.  
  752. function nettoieTitre(le_titre : String) : string;
  753. var
  754.   i : Integer;
  755. begin
  756.   i:=pos('(1',le_titre);
  757.   if i <> 0 then
  758.   begin
  759.     le_titre := copy(le_titre,1,i-1);
  760.     le_titre := Trim(le_titre);
  761.     result := le_titre;
  762.   end;
  763.   i:= 0;
  764.   i:=pos('(2',le_titre);
  765.   if i <> 0 then
  766.   begin
  767.     le_titre := copy(le_titre,1,i-1);
  768.     le_titre := Trim(le_titre);
  769.     result := le_titre;
  770.   end else
  771.     result := le_titre;
  772. end;
  773.  
  774. //------------------------------------------------------------------------------
  775. // SAISONS ET EPISODES
  776. //------------------------------------------------------------------------------
  777.  
  778. procedure saisonsETepisodes(adresse : String);
  779. var
  780.    Value, Line, Titre, Acteurs, Details, SaisonCourante : String;
  781.    listeSaison : TStringList;
  782. begin
  783. // Initialisation de la liste des saisons
  784.   listeSaison := TStringList.Create;
  785.  
  786.   Value := '';
  787.   sleep(timetosleep);
  788.   Line := GetPage(adresse);
  789.  
  790. // CrΘation de la liste des pages de saisons
  791.   listeSaison.Add(adresse); // Page courante
  792.   Value := findInfo('Choisir une saison', '</h4></div>', Line,'1');
  793.   repeat
  794.     adresse := '/series/episodes_gen_csaison='+findInfo('csaison=', '&cserie=', Value,'0')+'&cserie='+ID+'.html';
  795.     listeSaison.Add(urlAllocine+adresse);
  796.     Value := StringReplace(Value, adresse, '');
  797.   until findInfo('csaison=', '&cserie=', Value,'0') = '';
  798.  
  799.   for i:=0 to listeSaison.Count-1  do
  800.   begin
  801.       if i <> 0 then
  802.       begin
  803.         sleep(timetosleep);
  804.         Line := GetPage(listeSaison.GetString(i));
  805.       end;
  806. // Titre saison
  807.       Titre := findInfo('<h2 style=', '</h2></td>', Line,'-1');
  808.       Titre := supprSubString('"', '">', Titre);
  809. // Acteurs principaux de la saison
  810.       Acteurs := findInfo('<b>Acteurs principaux de cette saison</b>', '<b>Le casting complet</b>', Line,'1');
  811.       Acteurs := StringReplace(Acteurs, '<h5 style="color:gray">', ' (');
  812.       Acteurs := StringReplace(Acteurs, '</h5></td>', '), ');
  813.       Acteurs := StringReplace(Acteurs, '( (', '(');
  814.       Acteurs := StringReplace(Acteurs, ') )', ')');
  815.       Acteurs := StringReplace(Acteurs, '))', ')');
  816.       Acteurs := StringReplace(Acteurs, ',,', ',');
  817.       HTMLRemoveTags(Acteurs);
  818.       Acteurs := deleteTab(Acteurs);
  819.       Acteurs := deleteEnd(Acteurs,', ')+'.';
  820.       if Acteurs <> '' then
  821.         Acteurs := 'Acteurs principaux de cette saison : '+Acteurs;
  822. // Liste des Θpisodes
  823.       Details := findInfo('<b>Liste des Θpisodes</b>', '<b>Acteurs principaux de cette saison</b>', Line,'-1');
  824.       Details := deleteTab(Details);
  825.       Details := deleteMultiReturn(Details);
  826.       Details := StringReplace(Details, 'Episode ', #13#10#13#10+Titre+' - Episode ');
  827.       Details := StringReplace(Details, ' RΘsumΘ et casting', '');
  828.       Details := StringReplace(Details, ' - '+#13#10, ' - ');
  829.       Details := StringReplace(Details, #13#10+'Voir les diffusions', '');
  830.       if Details <> '' then
  831.         Details := 'Liste des Θpisodes : '+Details;
  832. // CrΘation de la page
  833.       Value := #13#10+Titre+#13#10#13#10+Acteurs+#13#10#13#10+Details;
  834. // Ajout des dΘtails
  835.       if (Value <> '') and (i <> 0) then
  836.          SetField(fieldComments, GetField(fieldComments)+Value)
  837.       else if (Value <> '') and (i = 0) then
  838.          SaisonCourante := Value;
  839.   end;
  840.   SetField(fieldComments, GetField(fieldComments)+SaisonCourante)
  841.   listeSaison.Free;
  842. end;
  843.  
  844. //------------------------------------------------------------------------------
  845. // RETOURNE LA CRITIQUE SPECTATEURS
  846. //------------------------------------------------------------------------------
  847.  
  848. procedure panelCritiquesSpectateurs(laLigne : String);
  849. var
  850.    Value, Line, ValueTemp, critique, Lurl : String;
  851.    ZeroaQuatre : Integer;
  852. begin
  853.    if pos(urlAllocineCriSpec, laLigne) <> 0 then
  854.       Lurl := urlAllocineCriSpec
  855.    else
  856.       Lurl :=  urlAllocineCriSpecS;
  857.    Value := '';
  858.    for ZeroaQuatre := 0 to 4 do
  859.    begin
  860.      sleep(timetosleep);
  861.      if pos(Lurl+ID+'¬e='+IntToStr(ZeroaQuatre)+'.html', laLigne) <> 0 then
  862.      begin
  863.       Line := GetPage(urlAllocine+Lurl+ID+'¬e='+IntToStr(ZeroaQuatre)+'.html');
  864.       delete(Line, 1, pos('<b>Critiques '+IntToStr(ZeroaQuatre)+' Θtoiles :</b>', Line)-1);
  865.       // nom et date
  866.       ValueTemp := findInfo('<h4><b>', '</h4><img', Line,'2');
  867.       critique := formatTitre(ValueTemp,GetOption('Casse Choisie'));
  868.       // Note
  869.       ValueTemp := findInfo('etoile_', '.gif', Line,'2');
  870.       critique := critique+' - Note : '+ValueTemp+ '/4 '+#13#10;
  871.       // la critique
  872.       ValueTemp := findInfo('<div align="justify"><h4>', '</h4></div>', Line,'2');
  873.       ValueTemp := StringReplace(ValueTemp, '    ', '');
  874.       if pos('Voir aussi : Toutes les critiques de ',ValueTemp) <> 0 then
  875.         ValueTemp := copy(ValueTemp, 1, pos('Voir aussi : Toutes les critiques de ',ValueTemp)-1);
  876.       critique := critique+ValueTemp;
  877.       Value := critique+#13#10#13#10+Value;
  878.      end;
  879.    end;
  880.    if Value <> '' then
  881.    begin
  882.      if pos(urlAllocineCriSpec, laLigne) <> 0 then
  883.         SetField(fieldComments, GetField(fieldComments)+'Critiques Spectateurs :'+#13#10#13#10+Value)
  884.      else
  885.        SetField(fieldComments, GetField(fieldComments)+#13#10#13#10+'Critiques Spectateurs :'+#13#10#13#10+Value);
  886.    end;
  887. end;
  888.  
  889.  
  890. //------------------------------------------------------------------------------
  891. // ANALYSE DE LA PAGE CRITIQUES PRESSE
  892. //------------------------------------------------------------------------------
  893.  
  894. procedure critiquesPresseComplet(pageCritiques: string);
  895. var
  896.   Line, LineSuivant, Value, pageSuivante, aucun :string;
  897.   BeginPos, EndPos : Integer;
  898. begin
  899. // pour eviter les time-out
  900.   sleep(timetosleep);
  901. // charge la page
  902.   Line := GetPage(pageCritiques);
  903.   LineSuivant := Line;
  904.   numPage := numPage + 1;
  905.   if Pos('<b>Critiques Presse</b>', Line) > 0 then
  906.   begin
  907. // Les critiques presses
  908.   BeginPos := Pos('<b>Critiques Presse</b>', Line);
  909.   Delete(Line, 1, BeginPos-1);
  910.   repeat
  911.       // DΘbut boucle
  912.       BeginPos := pos('<td valign="top"><h4><b>', Line);
  913.       delete(Line, 1, BeginPos-1);
  914.       // Journal et nom du critique
  915.       aucun := findInfo('<h4><b>', '</h4><img', Line,'0');
  916.       Value := formatTitre(aucun,GetOption('Casse Choisie'));
  917.       // Note
  918.       aucun := findInfo('etoile_', '.gif', Line,'0');
  919.       Value := Value+' - Note : '+aucun+ '/4 '+#13#10;
  920.       // la critique
  921.       aucun := findInfo('<div align="justify"><h4>', '</h4></div>', Line,'0');
  922.       aucun := StringReplace(aucun, '    ', '');
  923.       if pos('Voir aussi : La revue de presse de',aucun) <> 0 then
  924.         aucun := copy(aucun, 1, pos('Voir aussi : La revue de presse de',aucun)-1);
  925.       Value := Value+aucun+#13#10#13#10;
  926.       // Fin Boucle
  927.       delete(Line, 1, length('<td valign="top"><h4><b>'));
  928.       BeginPos := pos('<td valign="top"><h4><b>', Line);
  929.       // La critique dans la liste
  930.       La_liste := La_liste + Value;
  931.   until (BeginPos = 0);
  932.   SetField(fieldComments, La_liste);
  933. // si on a plusieurs pages
  934.   pageSuivante := pageCritiques;
  935.   delete(pageSuivante,1,pos('.fr', pageSuivante)+2);
  936.   pageSuivante := copy(pageSuivante, 1, pos('.html', pageSuivante)-1);
  937.   if pos('page',pageSuivante) = 0 then
  938.   begin
  939.     pageSuivante := pageSuivante+'&page='+IntToStr(numPage)+'.html';
  940.   end else
  941.   begin
  942.     pageSuivante := copy(pageSuivante, 1, pos('&page=', pageSuivante)-1)+'&page='+IntToStr(numPage)+'.html';
  943.   end;
  944.   BeginPos := pos(pageSuivante,LineSuivant);
  945.   if BeginPos <> 0 then
  946.   begin
  947.     pageSuivante := urlAllocine+pageSuivante;
  948.     critiquesPresseComplet(pageSuivante);
  949.   end;
  950.   end;
  951. end;
  952.  
  953. //------------------------------------------------------------------------------
  954. // RETOURNE LE LIEN VERS LA PREMIERE B.A.
  955. //------------------------------------------------------------------------------
  956.  
  957. function ladressedelaBA(Line : String) : String;
  958. var
  959.    Value : String;
  960. begin
  961.      if (pos('<b>Bandes<br />annonces</b></h5></a>',Line) <> 0) then
  962.      begin
  963.         sleep(timetosleep);
  964.         Line := GetPage(urlAllocine+'/film/video_gen_cfilm='+findInfo('/film/video_gen_cfilm=', '.html', Line,'0')+'.html');
  965.         sleep(timetosleep);
  966.         Line := GetPage(urlAllocine+'/webtv/acvision.asp?nopub=1&cvid='+findInfo('javascript:FenACVision(', ',', Line,'0')+'&player=ASF&debit=H&emission=');
  967.         Value := findInfo('_video/generation.asx?', '"', Line,'0');
  968.         if Value <> '' then
  969.           result := urlAllocine+'/_video/generation.asx?'+findInfo('_video/generation.asx?', '"', Line,'0')
  970.         else
  971.           result := '';
  972.      end else
  973.         result := '';
  974. end;
  975.  
  976. //------------------------------------------------------------------------------
  977. // RETOURNE L'ADRESSE DU CASTING COMPLET
  978. //------------------------------------------------------------------------------
  979.  
  980. function ladresseduCasting(Line : String) : String;
  981. begin
  982.  
  983.   SetArrayLength(listeMessagesF,2);
  984.   SetArrayLength(listeMessagesS,2);
  985.   listeMessagesF[0] := '/film/casting_gen_cfilm=';
  986.   listeMessagesS[0] := '/series/casting_gen_cserie=';
  987.   listeMessagesF[1] := '<b>Casting<br />complet</b></h5></a>';
  988.   listeMessagesS[1] := '<b>Casting complet</b></h5>';
  989.   if (pos(listeMessagesF[1],Line) <> 0) then
  990.       result := urlAllocine+listeMessagesF[0]+ID+'.html'
  991.   else if (pos(listeMessagesS[1],Line) <> 0) then
  992.       result := urlAllocine+listeMessagesS[0]+ID+'.html'
  993.   else
  994.       result := '';
  995. end;
  996.  
  997. //------------------------------------------------------------------------------
  998. // RETOURNE L'ADRESSE DES CRITIQUES PRESSE
  999. //------------------------------------------------------------------------------
  1000.  
  1001. function ladressedesCritiques(Line : String) : String;
  1002. begin
  1003.      if (pos('<b>Critiques<br />presse</b></h5></a>',Line) <> 0) then
  1004.         result := urlAllocine+'/film/revuedepresse_gen_cfilm='+findInfo('/film/revuedepresse_gen_cfilm=', '.html', Line,'0')+'.html'
  1005.      else
  1006.         result := '';
  1007. end;
  1008.  
  1009. //------------------------------------------------------------------------------
  1010. // RETOURNE L'ADRESSE DES SECRETS DE TOURNAGE
  1011. //------------------------------------------------------------------------------
  1012.  
  1013. function ladressedesSecrets(Line : String) : String;
  1014. begin
  1015.      if (pos('<b>Secrets de<br />tournage</b></h5></a>',Line) <> 0) then
  1016.         result := urlAllocine+'/film/anecdote_gen_cfilm='+findInfo('/film/anecdote_gen_cfilm=', '.html', Line,'0')+'.html'
  1017.      else
  1018.         result := '';
  1019. end;
  1020.  
  1021. //------------------------------------------------------------------------------
  1022. // ANALYSE DE LA PAGE CASTING
  1023. //------------------------------------------------------------------------------
  1024.  
  1025. procedure castingComplet(pageCasting: string);
  1026. var
  1027.   Line, Role, Acteur, couple, liste, Producteur :string;
  1028.   BeginPos, EndPos, OtherPos : Integer;
  1029. begin
  1030. //pour eviter les time-out
  1031.   sleep(timetosleep);
  1032.   SetArrayLength(listeMessagesF,2);
  1033.   SetArrayLength(listeMessagesS,2);
  1034.   if pos('cfilm=', pageCasting) <> 0 then
  1035.   begin
  1036.       listeMessagesF[0] := '<b>Acteur(s)</b>';
  1037.       listeMessagesF[1] := 'ScΘnario, production';
  1038.       listeMessagesS[0] := '<b>Acteur(s)</b>';
  1039.       listeMessagesS[1] := 'ScΘnario, production';
  1040.   end else if pos('cserie=', pageCasting) <> 0 then
  1041.   begin
  1042.       listeMessagesF[0] := '<b>Acteurs';
  1043.       listeMessagesF[1] := '<b>Acteurs';
  1044.       listeMessagesS[0] := '<b>Acteurs';
  1045.       listeMessagesS[1] := '<b>Acteurs';
  1046.   end;
  1047.  
  1048. //charge la page
  1049.   Line := GetPage(pageCasting);
  1050.   if CanSetField(fieldActors) then
  1051.   begin
  1052.     if Pos(retourneElement(0), Line) > 0 then
  1053.     begin
  1054. //liste des acteurs
  1055.       BeginPos := Pos(retourneElement(0), Line);
  1056.       Delete(Line, 1, BeginPos);
  1057.       BeginPos := Pos('<h5>', Line);
  1058.       liste := '';
  1059.       repeat
  1060.         BeginPos := Pos('<h5>', Line);
  1061.         delete(Line,1,BeginPos-1);
  1062. // le role
  1063.         Role := formatTitre(findInfo('<h5>', '</h5>', Line,'0'),GetOption('Format du Titre'));
  1064. // le nom de l'acteur
  1065.         Acteur := formatTitre(findInfo('<h4>', '</h4>', Line,'0'),GetOption('Format du Titre'));
  1066. // couple acteur (r⌠le)
  1067.         if (Role <> '') then
  1068.           couple := Acteur +' ('+Role+'), '
  1069.         else
  1070.           couple := Acteur +', ';
  1071. // ajout du couple dans la liste
  1072.          liste := liste + couple;
  1073.          delete(Line, 1, length('<h5>'));
  1074.          BeginPos := pos('<h5>', Line);
  1075.          OtherPos := pos(retourneElement(1), Line);
  1076.       until (BeginPos > OtherPos);
  1077.       EndPos := length(liste);
  1078.       liste := copy(liste,1,EndPos-2)+'.';
  1079.       MonSetField(fieldActors, liste);
  1080.     end;
  1081.   end;
  1082. // le producteur
  1083.   if CanSetField(fieldProducer) and (pos('casting_gen_cserie',pageCasting) = 0) then
  1084.     MonSetField(fieldProducer, formatTitre(StringReplace(findInfo('<h5>Producteur', '</h4>', Line,'0'), '    ', ''),GetOption('Casse Choisie')));
  1085. end;
  1086.  
  1087. //------------------------------------------------------------------------------
  1088. // ANALYSE DE LA PAGE SECRETS DE TOURNAGE
  1089. //------------------------------------------------------------------------------
  1090.  
  1091. procedure secretComplet(pageSecret: string);
  1092. var
  1093.   Line, LineSuivant, Titre, Texte, couple, pageSuivante :string;
  1094.   BeginPos, EndPos : Integer;
  1095. begin
  1096. //pour eviter les time-out
  1097.   sleep(timetosleep);
  1098. //charge la page
  1099.   Line := GetPage(pageSecret);
  1100.   LineSuivant := Line;
  1101.   numPage := numPage + 1;
  1102.   if Pos('Secrets de tournage</h2>', Line) > 0 then
  1103.   begin
  1104. //liste des secrets
  1105.   BeginPos := Pos('Secrets de tournage</h2>', Line);
  1106.   Delete(Line, 1, BeginPos);
  1107.   BeginPos := Pos('<td colspan="3" valign="top" style="padding:">', Line);
  1108.   repeat
  1109.      BeginPos := pos('<td colspan="3" valign="top" style="padding:">', Line);
  1110.      delete(Line, 1, BeginPos-1);
  1111.      // titre
  1112.      Titre := findInfo('<td colspan="3" valign="top" style="padding:">', '</b></h4></td>', Line,'0');
  1113.      Titre := formatTitre(Titre,GetOption('Casse Choisie'))+#13#10;
  1114.      // secret
  1115.      Texte := findInfo('justify"><h4>', '</h4></div></td>', Line,'0')+#13#10#13#10;
  1116.      // couple
  1117.      couple := Titre+Texte;
  1118.      La_liste := La_liste+couple;
  1119.      delete(Line, 1, length('<td colspan="3" valign="top" style="padding:">'));
  1120.      BeginPos := pos('<td colspan="3" valign="top" style="padding:">', Line);
  1121.   until (BeginPos = 0);
  1122.   SetField(fieldComments, La_liste);
  1123. // si on a plusieurs pages
  1124.   pageSuivante := pageSecret;
  1125.   delete(pageSuivante,1,pos('.fr', pageSuivante)+2);
  1126.   pageSuivante := copy(pageSuivante, 1, pos('.html', pageSuivante)-1);
  1127.   if pos('page',pageSuivante) = 0 then
  1128.   begin
  1129.     pageSuivante := pageSuivante+'&page='+IntToStr(numPage)+'.html';
  1130.   end else
  1131.   begin
  1132.     pageSuivante := copy(pageSuivante, 1, pos('&page=', pageSuivante)-1)+'&page='+IntToStr(numPage)+'.html';
  1133.   end;
  1134.   BeginPos := pos(pageSuivante,LineSuivant);
  1135.   if BeginPos <> 0 then
  1136.   begin
  1137.     pageSuivante := urlAllocine+pageSuivante;
  1138.     secretComplet(pageSuivante);
  1139.   end;
  1140.   end;
  1141. end;
  1142.  
  1143. //------------------------------------------------------------------------------
  1144. // AJOUTE UN COUPLE FILM / ADRESSE A LA LISTE DE RESULTAT
  1145. //------------------------------------------------------------------------------
  1146.  
  1147. procedure AddMoviesTitles(Line : string);
  1148. var
  1149.   MovieTitle, MovieTitle2, MovieAddress, aucun, annee : string;
  1150.   StartPos, EndPos : Integer;
  1151. begin
  1152. //compte les rΘsultats
  1153.   compteur := 0;
  1154.   listeResultat := TStringList.Create;
  1155.   PickTreeAdd('Films trouvΘs pour ' + MovieName + ' :', '');
  1156.   Line := '<td colspan="2" valign="top">'+Line;
  1157.   repeat
  1158.       StartPos := pos('<td colspan="2" valign="top">', Line);                   // Pour la boucle
  1159.       delete(Line, 1, StartPos-1);                                              // Pour la boucle
  1160.       MovieAddress := urlAllocine+findInfo('<h4><a href="', '"', Line,'0');
  1161.       MovieTitle2 := findInfo('<h4>', '</h4>', Line,'0');
  1162.       MovieTitle := StringReplace(findInfo('<h4>', '</td>', Line,'0'), '    ', '');
  1163. // si on a des informations complΘmentaires
  1164.       annee := copy(MovieTitle,length(MovieTitle)-4,4);
  1165.       if IsAnneValide(annee) then
  1166.       begin
  1167.           MovieTitle := StringReplace(MovieTitle, '('+annee+')', '');
  1168.           MovieTitle := '['+annee+'] '+MovieTitle;
  1169.       end;
  1170. // Pour le mode batch le titre doit Ωtre "propre"
  1171.       listeResultat.Add(MovieTitle2+'|'+MovieAddress+'['+annee+']');
  1172.       PickTreeAdd(MovieTitle, MovieAddress);
  1173.       delete(Line, 1, length('<td colspan="2" valign="top">'));
  1174.       StartPos := pos('<td colspan="2" valign="top">', Line);                   // Pour la boucle
  1175.       compteur := compteur+1;                                                   // Pour la boucle
  1176.   until (StartPos = 0);
  1177.  
  1178. // si on a plus de rΘsultats
  1179.   StartPos := pos('Plus de films',Line);
  1180.   if StartPos <> 0 then
  1181.   begin
  1182.     AdressePlus := urlAllocineSearch+UrlEncode(MovieName)+'&rub=1&page='+IntToStr(numPageR);
  1183.     PickTreeAdd('Plus de rΘsultats',AdressePlus);
  1184.   end;
  1185.   numTemp := numPageR-1;
  1186.   strTemp := IntToStr(numTemp);
  1187.   if pos('<a href="/recherche/?motcle='+MovieName+'&rub=1&page='+strTemp,Line) <> 0 then
  1188.   begin
  1189.     AdressePrecedent := urlAllocineSearch+UrlEncode(MovieName)+'&rub=1&page='+strTemp;
  1190.     PickTreeAdd('Films prΘcΘdents',AdressePrecedent);
  1191.   end;
  1192.   numTemp := numPageR+1;
  1193.   strTemp := IntToStr(numTemp);
  1194.   if pos('<a href="/recherche/?motcle='+MovieName+'&rub=1&page='+strTemp,Line) <> 0 then
  1195.   begin
  1196.     AdresseSuivant := urlAllocineSearch+UrlEncode(MovieName)+'&rub=1&page='+strTemp;
  1197.     PickTreeAdd('Films suivants',AdresseSuivant);
  1198.   end;
  1199. end;
  1200.  
  1201. function IsAnneValide(src : String) : Boolean;
  1202. var
  1203.   Num : String;
  1204.   j : Integer;
  1205. begin
  1206. Num := '0123456789';
  1207. for j := 1 to 4 do
  1208.   if (pos(copy(src,j,1), Num) = 0) then
  1209.   begin
  1210.     result := False;
  1211.     exit;
  1212.   end else
  1213.     result := True;
  1214. end;
  1215.  
  1216. //------------------------------------------------------------------------------
  1217. // IMPORTE GRANDE AFFICHE ALLOCINE
  1218. //------------------------------------------------------------------------------
  1219.  
  1220. procedure returnGrandeImage(Line : String);
  1221. begin
  1222.      if aucunAmazon = 'aucune image' then
  1223.      begin
  1224.        if (pos('<b>Galerie<br />Photos</b></h5></a>',Line) <> 0) then
  1225.        begin
  1226.           sleep(timetosleep);
  1227.           Line := GetPage(urlAllocine+'/film/galerievignette_gen_cfilm='+findInfo('/film/galerievignette_gen_cfilm=', '.html', Line,'0')+'.html');
  1228.           if Line <> '' then
  1229.           begin
  1230.             sleep(timetosleep);
  1231.             Line := GetPage(urlAllocine+'/film/galerie_gen_cfilm='+findInfo('/film/galerie_gen_cfilm=', '"', Line,'0'));
  1232.             if Line <> '' then
  1233.             begin
  1234.               delete(Line,1, pos('<td  align="center" colspan="2">', Line));
  1235.               GetPicture(findInfo('<img src="', '"', Line,'0'));
  1236.               aucunAmazon := 'ok';
  1237.             end else
  1238.             begin aucunAmazon := 'aucune image'; end;
  1239.           end else
  1240.           begin aucunAmazon := 'aucune image'; end;
  1241.        end else
  1242.        begin aucunAmazon := 'aucune image'; end;
  1243.      end;
  1244. end;
  1245.  
  1246. //------------------------------------------------------------------------------
  1247. // IMPORTE PETITE AFFICHE ALLOCINE
  1248. //------------------------------------------------------------------------------
  1249.  
  1250. procedure returnPetiteImage(Line : String);
  1251. var
  1252.    BeginPos, EndPos : Integer;
  1253. begin
  1254.    if aucunAmazon = 'aucune image' then
  1255.    begin
  1256.      if (pos('Toute la Galerie Photos', Line) > 0) and (pos('AffichetteAllocine.gif', Line) =0) then
  1257.      begin
  1258.        delete(Line,1, pos('<td valign="top" style="padding:0 10 5 0">', Line));
  1259.        GetPicture(findInfo('width="100%"><img src="', '" border', Line,'0'));
  1260.        aucunAmazon := 'ok';
  1261.      end else
  1262.      begin
  1263.        aucunAmazon := 'aucune image';
  1264.      end;
  1265.    end;
  1266. end;
  1267.  
  1268. //------------------------------------------------------------------------------
  1269. // IMPORTE IMAGE SERIE ALLOCINE
  1270. //------------------------------------------------------------------------------
  1271.  
  1272. procedure returnSerieImage(Line : String);
  1273. var
  1274.    BeginPos, EndPos : Integer;
  1275. begin
  1276.    if aucunAmazon = 'aucune image' then
  1277.    begin
  1278.      if (pos('<td valign="top" style="padding:0 0 5 0" width="100%"><img src="', Line) > 0) and (pos('AffichetteSerieAllocine.gif', Line) =0) then
  1279.      begin
  1280.        GetPicture(findInfo('<td valign="top" style="padding:0 0 5 0" width="100%"><img src="', '"', Line,'0'));
  1281.        aucunAmazon := 'ok';
  1282.      end else
  1283.      begin
  1284.        aucunAmazon := 'aucune image';
  1285.      end;
  1286.    end;
  1287. end;
  1288.  
  1289. //------------------------------------------------------------------------------
  1290. // RECUPERE GRANDE IMAGE AMAZON.FR
  1291. //------------------------------------------------------------------------------
  1292.  
  1293. procedure imageAmazon(title : String);
  1294. var
  1295.   adresseRecherche, Line : String;
  1296.   StartPos: Integer;
  1297. begin
  1298.   if aucunAmazon = 'aucune image' then
  1299.   begin
  1300.     adresseRecherche := 'http://www.amazon.fr/exec/obidos/search-handle-url/index=dvd-fr&field-keywords='+UrlEncode(title);
  1301.     Line := GetPage(adresseRecherche);
  1302.     if pos('satisfaisante pour votre recherche sur', Line) > 0 then
  1303.     begin
  1304.       aucunAmazon := 'aucune image';
  1305.       exit;
  1306.     end else
  1307.     if (pos('Sur ce DVD', Line) > 0)  or (pos('Amazon.fr : DVD:', Line) > 0) then
  1308.     begin
  1309.         StartPos := pos('<b class="sans">', Line);
  1310.         delete(Line, 1, StartPos-1);
  1311.         importAmazon(Line);
  1312.     end else
  1313.     if pos('résultats au total pour', Line) > 0 then
  1314.     begin
  1315.         StartPos := pos('résultats au total pour', Line);
  1316.         delete(Line, 1, StartPos);
  1317.         TrouveTitle(Line, title);
  1318.     end;
  1319.   end;
  1320. end;
  1321.  
  1322. //------------------------------------------------------------------------------
  1323. // RECUPERE GRANDE IMAGE CINEFIL.COM
  1324. //------------------------------------------------------------------------------
  1325.  
  1326. procedure imageCinefil(title : String);
  1327. var
  1328.   CinefilBase, CinefilUrl, CinefilUrlLook, adresseRecherche, Line : String;
  1329.   StartPos: Integer;
  1330. begin
  1331.   if aucunAmazon = 'aucune image' then
  1332.   begin
  1333.     CinefilBase := 'http://www.cinefil.com';
  1334.     CinefilUrl  := CinefilBase + '/cinefil2005/';
  1335.     CinefilUrlLook := CinefilUrl + 'CFM_Recherches/films.cfm?lachaine2=';
  1336.     adresseRecherche := CinefilUrlLook+UrlEncode(title);
  1337.     Sleep(timetosleep);
  1338.     Line := GetPage(adresseRecherche);
  1339.     if pos('RΘsultat 0 film', Line) > 0 then
  1340.     begin
  1341.       aucunAmazon := 'aucune image';
  1342.       exit;
  1343.     end else
  1344.     begin
  1345.       recupCinefil(Line, title);
  1346.     end;
  1347.   end;
  1348. end;
  1349.  
  1350. //------------------------------------------------------------------------------
  1351. // SUPPRIME LES ACCENTS
  1352. //------------------------------------------------------------------------------
  1353.  
  1354. function supprimeAccents(NomFilm : String) : String;
  1355. begin
  1356.      NomFilm := supprimeLesAccents(NomFilm);
  1357.      delete(NomFilm, pos(' - ',NomFilm), length(NomFilm));
  1358.      if (pos(', ',NomFilm) > 0) then
  1359.         delete(NomFilm, 1, pos(', ',NomFilm)+1);
  1360.      if (pos('(',NomFilm) > 0) then
  1361.         delete(NomFilm, pos('(',NomFilm), length(NomFilm));
  1362.      if (pos(':',NomFilm) > 0) then
  1363.         delete(NomFilm, pos(':',NomFilm), length(NomFilm));
  1364.      result := trim(NomFilm);
  1365. end;
  1366.  
  1367. //------------------------------------------------------------------------------
  1368. // RECUPERE L'IMAGE CINEFIL
  1369. //------------------------------------------------------------------------------
  1370.  
  1371. procedure recupCinefil(Line, title : String);
  1372. var
  1373.    test, lecouple, letitreCinefil, limageCinefil, temp : String;
  1374.    StartPos, i : Integer;
  1375. begin
  1376.    i := 0;
  1377.    StartPos := pos('RΘsultat', Line);
  1378.    delete(Line, 1, StartPos-1);
  1379.    StartPos := pos('</table>', Line);
  1380.    delete(Line, 1, StartPos+7);
  1381.    delete(Line, 1, pos('<TR><TD align=center colspan=7>',Line)+length('<TR><TD align=center colspan=7>'));
  1382.    StartPos := pos('[', Line);
  1383.    repeat
  1384.      delete(Line, 1, StartPos-1);
  1385.      // L'annΘe du film CINEFILM
  1386.      lanneeCinefil := copy(Line,0,pos(']',Line));
  1387.      lecouple := recupTitleAdresseCinefil(Line);
  1388.      letitreCinefil := copy(lecouple,0,pos('|',lecouple)-1);
  1389.      limageCinefil := copy(lecouple,pos('|',lecouple)+1,length(lecouple)-1);
  1390.      test := compareTitle(title,letitreCinefil);
  1391.      if test = 'OK' then
  1392.      begin
  1393.        i :=i+1;
  1394.        Sleep(timetosleep);
  1395.        temp := GetPage('http://www.cinefil.com/cinefil2005/fichefilm.cfm?ref='+limageCinefil);
  1396.        if (lanneeCinefil = lannee) then
  1397.        begin
  1398.          if pos('ImagesCinefil/AfficheGrandFormat/a'+limageCinefil+'.jpeg', temp) <> 0 then
  1399.          begin
  1400.              GetPicture('http://www.cinefil.com/ImagesCinefil/AfficheGrandFormat/a'+limageCinefil+'.jpeg');
  1401.              aucunAmazon := 'ok';
  1402.          end else
  1403.          begin
  1404.              test := 'KO';
  1405.              aucunAmazon := 'aucune image';
  1406.          end;
  1407.        end else
  1408.        begin
  1409.          test := 'KO';
  1410.          aucunAmazon := 'aucune image';
  1411.        end;
  1412.      end;
  1413.      StartPos := pos('</TD></TR>', Line);
  1414.      delete(Line, 1, StartPos-1);
  1415.      StartPos := pos('[', Line);
  1416.   until (StartPos = 0) or  (test = 'OK');
  1417.   if (test = 'KO') and (i = 1) then
  1418.   begin
  1419.      if pos('ImagesCinefil/AfficheGrandFormat/a'+limageCinefil+'.jpeg', temp) <> 0 then
  1420.      begin
  1421.        GetPicture('http://www.cinefil.com/ImagesCinefil/AfficheGrandFormat/a'+limageCinefil+'.jpeg');
  1422.        aucunAmazon := 'ok';
  1423.        test := 'OK';
  1424.      end else
  1425.      begin
  1426.        test := 'KO';
  1427.        aucunAmazon := 'aucune image';
  1428.      end;
  1429.   end else
  1430.   if test = 'KO' then
  1431.      aucunAmazon := 'aucune image';
  1432. end;
  1433.  
  1434. //------------------------------------------------------------------------------
  1435. // RECUPERE LE TITRE / ADRESSE / ANNEE CINEFIL
  1436. //------------------------------------------------------------------------------
  1437.  
  1438. function recupTitleAdresseCinefil(Line : String) : String;
  1439. var
  1440.    title, adresseCinefil : String;
  1441.    StartPos: Integer;
  1442. begin
  1443.      StartPos := pos('href="', Line);
  1444.      delete(Line, 1, StartPos+5);
  1445. // Adresse image du film CINEFILM
  1446.      StartPos := pos('ref=', Line);
  1447.      delete(Line, 1, StartPos+3);
  1448.      adresseCinefil := copy(Line, 1,pos('''', Line)-1);
  1449.      StartPos := pos('">', Line);
  1450.      delete(Line, 1, StartPos+1);
  1451. // Titre du film CINEFILM
  1452.      title := copy(Line,1, pos('</a>', Line)-1);
  1453.      title := StringReplace(title, '├á ', 'a ');
  1454.      title := StringReplace(title, '├⌐', 'Θ');
  1455.      title := StringReplace(title, '├¿', 'Φ');
  1456.      result := title+'|'+adresseCinefil;
  1457. end;
  1458.  
  1459. //------------------------------------------------------------------------------
  1460. // ANNEE FILM COURANT POUR AMELIORER PERTINENCE CINEFIL
  1461. //------------------------------------------------------------------------------
  1462. procedure anneeFilmCourant(Line : String);
  1463. var
  1464.   EndPos : Integer;
  1465. begin
  1466.     if pos('<h4>AnnΘe de production : ', Line) > 0 then
  1467.     begin
  1468.       Delete(Line, 1, pos('<h4>AnnΘe de production : ', Line)+24);
  1469.       EndPos := pos('</h4>', Line);
  1470.       lannee := '['+Trim(copy(Line, 1, EndPos -1))+']';
  1471.     end;
  1472. end;
  1473.  
  1474. //------------------------------------------------------------------------------
  1475. // IMPORTE L'IMAGE AMAZON
  1476. //------------------------------------------------------------------------------
  1477.  
  1478. procedure importAmazon(Line : String);
  1479. var
  1480.    ImageAddress : String;
  1481.    StartPos: Integer;
  1482. begin
  1483.      StartPos := pos(urlAmazonImage, Line);
  1484.      delete(Line, 1, StartPos-1);
  1485.      ImageAddress := copy(Line, 0, pos('"', Line) - 1);
  1486.      ImageAddress := StringReplace(ImageAddress, 'THUMBZZZ', 'LZZZZZZZ');
  1487.      Sleep(timetosleep);
  1488.      GetPicture(ImageAddress);
  1489.      aucunAmazon := 'ok';
  1490. end;
  1491.  
  1492. //------------------------------------------------------------------------------
  1493. // RECUPERE LE TITRE AMAZON
  1494. //------------------------------------------------------------------------------
  1495.  
  1496. function recupTitle(Line : String) : String;
  1497. var
  1498.    title : String;
  1499.    StartPos: Integer;
  1500. begin
  1501.      StartPos := pos('<b>', Line);
  1502.      delete(Line, 1, StartPos-1);
  1503.      title := copy(Line, 1, pos('</b></a>', Line)-1);
  1504.      HTMLRemoveTags(title);
  1505.      title := StringReplace(title, #13#10, '');
  1506.      result := title;
  1507. end;
  1508.  
  1509. //------------------------------------------------------------------------------
  1510. // COMPARE LE TITRE PASSE ET LE TITRE TROUVE
  1511. //------------------------------------------------------------------------------
  1512.  
  1513. function compareTitle(titleAllo, title : String) : String;
  1514. begin
  1515.      title := supprimeAccents(trim(AnsiLowerCase(title)));
  1516.      titleAllo := supprimeAccents(trim(AnsiLowerCase(titleAllo)));
  1517.      if (title = titleAllo) then
  1518.      begin
  1519.        result := 'OK';
  1520.      end else
  1521.      begin
  1522.        result := 'KO';
  1523.      end;
  1524. end;
  1525.  
  1526. //------------------------------------------------------------------------------
  1527. // TROUVE LE BON TITRE SI LE PREMIER N'EST PAS LE BON
  1528. //------------------------------------------------------------------------------
  1529.  
  1530. procedure trouveTitle(Line, title : String);
  1531. var
  1532.    StartPos: Integer;
  1533.    oK : String;
  1534. begin
  1535.    StartPos := pos('/exec/obidos/ASIN/', Line);
  1536.    repeat
  1537. {*********************** Boucle DEBUT ***********************}
  1538.      StartPos := pos('/exec/obidos/ASIN/', Line);
  1539.      delete(Line, 1, StartPos+length('/exec/obidos/ASIN/')-1);
  1540. {*********************** Boucle DEBUT ***********************}
  1541.      oK := compareTitle(title,recupTitle(Line));
  1542.      if oK = 'OK' then
  1543.        importAmazon(Line);
  1544. {*********************** Boucle FIN ***********************}
  1545.      StartPos := pos('<a href=/exec/obidos/ASIN/', Line);
  1546.      delete(Line, 1, StartPos+length('<a href=/exec/obidos/ASIN/')-1);
  1547.      StartPos := pos('/exec/obidos/ASIN/', Line);
  1548. {*********************** Boucle FIN ***********************}
  1549.   until (StartPos = 0) or  (oK = 'OK');
  1550.   if oK = 'KO' then
  1551.      aucunAmazon := 'aucune image';
  1552. end;
  1553.  
  1554. //------------------------------------------------------------------------------
  1555. // PROGRAMME PRINCIPAL
  1556. //------------------------------------------------------------------------------
  1557.  
  1558. begin
  1559.   if CheckVersion(3,5,0) then
  1560.   begin
  1561.     if GetOption('Mise α jour') = 0 then
  1562.     begin
  1563.        execMenuMAJ(VersionScript,NomScript);
  1564.        exit;
  1565.     end;
  1566.     numPageR := 1;
  1567.     MovieName := recupTitreRecherche(GetOption('Recherche sur le titre'));
  1568.     SetArrayLength(listeMessagesF,1);
  1569.     SetArrayLength(listeMessagesS,1);
  1570.     listeMessagesF[0] := urlAllocineSearchEndFilm;
  1571.     listeMessagesS[0] := urlAllocineSearchEndSeries;
  1572.     if (GetOption('Fichier de log') = 0) and (premiereExecution = 0) then
  1573.     begin
  1574.       batch(NomScript);
  1575.       AddToLog('Les films ayant ΘtΘ mis α jour sont maintenant cochΘs');
  1576.     end;
  1577.     if (GetOption('Type de Lancement') = 1) then
  1578.     begin
  1579.       if Input(NomScript+' by ScorEpioN', 'Entrez le titre du film :', MovieName) then
  1580.       begin
  1581.         if Pos(urlDomain, MovieName) > 0 then
  1582.           AnalyzeMoviePage(convertURL(MovieName))
  1583.         else
  1584.           AnalyzePage(urlAllocineSearch+UrlEncode(MovieName)+retourneElement(0));
  1585.       end;
  1586.     end else
  1587.     if (GetOption('Type de Lancement') = 3) then
  1588.     begin
  1589.       if (premiereExecution = 0) then
  1590.       begin
  1591.         premiereExecution := -1;
  1592.         if (ShowConfirmation('Vous allez executer le script sans confirmation, cliquer sur ''''OUI'''' pour continuer') = False) then
  1593.            exit;
  1594.       end;
  1595.       Sleep(timetosleep);
  1596.       MovieName := GetField(fieldURL);
  1597.       if Pos(urlDomain, MovieName) > 0 then
  1598.          AnalyzeMoviePage(convertURL(MovieName));
  1599.     end else
  1600.     begin
  1601.       if (premiereExecution = 0) then
  1602.       begin
  1603.           premiereExecution := -1;
  1604.           if (ShowConfirmation('Vous allez executer le script sans confirmation, cliquer sur ''''OUI'''' pour continuer') = True) then
  1605.           begin
  1606.             AnalyzePage(urlAllocineSearch+UrlEncode(MovieName)+retourneElement(0));
  1607.           end else
  1608.             exit;
  1609.       end else
  1610.       begin
  1611.           Sleep(timetosleep);
  1612.           AnalyzePage(urlAllocineSearch+UrlEncode(MovieName)+retourneElement(0));
  1613.       end;
  1614.     end;
  1615.   end else
  1616.     ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
  1617. end.
  1618.